#coding=utf-8

from common.import_common import *

from question.models import Question
from vote.forms import VoteForm


def vote(request, qid):
    """ vote & add opinion"""
    question = get_object_or_404(Question, pk=qid)
    if request.method == 'POST':
        form = VoteForm(request, data=request.POST)
        if form.is_valid():
            form.save(request.user, question)
            return HttpResponseRedirect("/question/%s/"%qid)

